import index from '@/components/index.vue'
import home from '@/components/home.vue'
import tecnoogie from '@/components/tecnoogie.vue'
import formazione from '@/components/formazione.vue'
import ricerca from '@/components/ricerca.vue'
import distributors from '@/components/distributors.vue'
import news from '@/components/news.vue'
import careers from '@/components/careers.vue'
import  contatti from '@/components/contatti.vue'



import * as VueRouter from 'vue-router'


const routes = [
    { path: '/', redirect: 'index' },
    {
        path: '/index', redirect: 'home', component: index, children: [
            { path: '/home', component: home },
            { path: '/tecnoogie', component: tecnoogie },
            { path: '/formazione', component: formazione },
            { path: '/ricerca', component: ricerca },
            { path: '/distributors', component: distributors },
            { path: '/news', component: news },
            { path: '/careers', component: careers },
            { path: '/contatti', component: contatti },
        ]
    }
]

const router = VueRouter.createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: VueRouter.createWebHashHistory(),
    routes, // `routes: routes` 的缩写
})

// 页面重新回到顶部
router.afterEach((to, from, next) => {
    window.scrollTo(0, 0);
    // chrome
    document.body.scrollTop = 0
    // firefox
    document.documentElement.scrollTop = 0
    // safari
    window.pageYOffset = 0
});



export default router